home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Screens / LoadPicture.s < prev    next >
Encoding:
Text File  |  1998-08-31  |  4.3 KB  |  174 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This demo will load in a picture of any size/type and if it is larger than
  3. ;the screen width, it scrolls left and right.  This is easily possible due
  4. ;to the fact that GMS likes to fill in fields that have been set at zero
  5. ;on initialisation, which is great for loading/displaying things like
  6. ;pictures.
  7. ;
  8. ;The benefits of this will become more apparent when you want to do things
  9. ;like changing your graphics format from ECS to AGA and vice versa.  The
  10. ;benefits for the user are enormous (full graphical editing capabilities,
  11. ;if you program correctly).  And you don't even need to change a line of
  12. ;code!
  13.  
  14.     INCDIR    "GMSDev:Includes/"
  15.     INCLUDE    "dpkernel/dpkernel.i"
  16.  
  17. SPEED    =    2
  18.  
  19.     SECTION    "Demo",CODE
  20.  
  21. ;===========================================================================;
  22. ;                             INITIALISE DEMO
  23. ;===========================================================================;
  24.  
  25.     STARTDPK
  26.  
  27. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  28.     move.l    DPKBase(pc),a6
  29.     lea    PictureFile(pc),a0
  30.     moveq    #ID_PICTURE,d0
  31.     CALL    Load
  32.     move.l    d0,Picture
  33.     beq.s    .Exit
  34.  
  35.     moveq    #ID_SCREEN,d0
  36.     CALL    Get
  37.     move.l    d0,Screen
  38.     beq.s    .Exit
  39.  
  40.     move.l    Picture(pc),a0    ;a0 = Source structure.
  41.     move.l    Screen(pc),a1    ;a1 = Destination structure.
  42.     move.l    #SCR_HSCROLL,GS_Attrib(a1)
  43.     CALL    CopyStructure    ;>> = Copy Picture to Screen.
  44.  
  45.     move.l    Screen(pc),a0
  46.     move.l    GS_Bitmap(a0),a1
  47.     clr.l    BMP_Palette(a1)
  48.     or.l    #BMF_BLANKPALETTE,BMP_Flags(a1)
  49.     sub.l    a1,a1
  50.     CALL    Init
  51.     tst.l    d0
  52.     beq.s    .Exit
  53.  
  54.     move.l    Picture(pc),a0
  55.     move.l    PIC_Bitmap(a0),a0
  56.     move.l    Screen(pc),a1
  57.     move.l    GS_Bitmap(a1),a1
  58.     CALL    Copy
  59.  
  60.     moveq    #ID_JOYDATA,d0    ;Get joydata structure for reading
  61.     CALL    Get    ;port 0.
  62.     move.l    d0,JoyData
  63.     beq.s    .Exit
  64.     move.l    d0,a0    ;Initialise the joydata structure.
  65.     sub.l    a1,a1
  66.     CALL    Init
  67.     tst.l    d0
  68.     beq.s    .Exit
  69.  
  70.     move.l    Screen(pc),a0
  71.     CALL    Display
  72.  
  73.     bsr.s    Main    ;Go and do the main routine.
  74.  
  75. .Exit    move.l    DPKBase(pc),a6
  76.     move.l    JoyData(pc),a0
  77.     CALL    Free
  78.     move.l    Screen(pc),a0
  79.     CALL    Free
  80.     move.l    Picture(pc),a0
  81.     CALL    Free
  82.     MOVEM.L    (SP)+,A0-A6/D1-D7
  83.     moveq    #ERR_OK,d0
  84.     rts
  85.  
  86. ;===========================================================================;
  87. ;                                MAIN LOOP
  88. ;===========================================================================;
  89.  
  90. Main:    move.l    SCRBase(pc),a6
  91.     move.l    Picture(pc),a2
  92.     moveq    #0,d7    ;d7 = Initialise fader.
  93.     moveq    #$000000,d2
  94.     moveq    #0,d3
  95.     move.l    PIC_Bitmap(a2),a5
  96.     move.l    BMP_AmtColours(a5),d4
  97.  
  98. .Fade1    move.l    Screen(pc),a0
  99.     CALL    scrWaitVBL
  100.     move.l    Screen(pc),a0
  101.     move.l    Picture(pc),a5
  102.     move.l    PIC_Bitmap(a5),a5
  103.     moveq    #2,d1    ;d1 = Speed of fade.
  104.     move.l    BMP_Palette(a5),a1    ;a1 = Palette we are fading to.
  105.     addq.w    #8,a1
  106.     move.w    d7,d0
  107.     CALL    scrColourToPalette    ;>> = Do the fade routine.
  108.     move.w    d0,d7    ;d7 = Fade counter.
  109.     bne.s    .Fade1    ;>> = If not finished, keep looping.
  110.  
  111. ;---------------------------------------------------------------------------;
  112. ;Loop here.
  113.  
  114.     moveq    #SPEED,d2
  115.  
  116. .loop    move.l    SCRBase(pc),a6
  117.     move.l    Screen(pc),a0
  118.     CALL    scrWaitAVBL
  119.  
  120.     move.l    Screen(pc),a0    ;a0 = Screen
  121.     move.l    GS_Bitmap(a0),a2    ;a1 = Screen.Bitmap
  122.     move.w    GS_Width(a0),d0    ;d0 = Screen.Width
  123.     cmp.w    BMP_Width(a2),d0    ;d0 = (Screen.Width >= Bitmap.Width)?
  124.     bge.s    .done    ;>> = Yes, do not scroll.
  125.  
  126.     tst.w    d2
  127.     bgt.s    .Right
  128.  
  129. .Left    tst.w    GS_BmpXOffset(a0)
  130.     ble.s    .RRight
  131.  
  132. .RLeft    moveq    #-SPEED,d2
  133.     bra.s    .scroll
  134.  
  135. .Right    move.w    BMP_Width(a2),d0    ;d0 = PicWidth.
  136.     sub.w    #320,d0
  137.     cmp.w    GS_BmpXOffset(a0),d0    ;d0 = Is (Width-320 < BmpOffset)?
  138.     ble.s    .RLeft
  139.  
  140. .RRight    moveq    #+SPEED,d2
  141.  
  142. .scroll    move.w    GS_BmpXOffset(a0),d0
  143.     add.w    d2,d0
  144.     move.w    GS_BmpYOffset(a0),d1
  145.     CALL    scrSetBmpOffsets
  146.  
  147. .done    move.l    DPKBase(pc),a6
  148.     move.l    JoyData(pc),a0
  149.     CALL    Query
  150.     move.l    JoyData(pc),a0
  151.     move.l    JD_Buttons(a0),d0
  152.     btst    #JB_LMB,d0
  153.     beq.s    .loop
  154.     rts
  155.  
  156. ;===========================================================================;
  157. ;                                  DATA
  158. ;===========================================================================;
  159.  
  160. Screen:        dc.l  0
  161. Picture:    dc.l  0
  162. JoyData:    dc.l  0
  163.  
  164. PictureFile:    FILENAME  "GMSDev:Logos/GMSLogo-FullScreen.iff"
  165.  
  166. ;===========================================================================;
  167.  
  168. ProgName:    dc.b  "Load Picture",0
  169. ProgAuthor:    dc.b  "Paul Manias",0
  170. ProgDate:    dc.b  "January 1998",0
  171. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  172. ProgShort:    dc.b  "Loads and displays any IFF picture.",0
  173.         even
  174.